<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>1F钢架E化方案 - 后台管理 - 职工添加</title>
  <%@include file="/WEB-INF/common/css.jsp"%>
  
  <%@include file="/WEB-INF/common/topjs.jsp"%>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
  
  <%@include file="/WEB-INF/common/admin/header.jsp"%>
  <%@include file="/WEB-INF/common/admin/menu.jsp"%>
  
  <div class="layui-body">
    <!-- 内容主体区域 -->
    <div style="padding: 15px;">
    	<div class="layui-col-md4">
    		<h3>职工添加</h3>
			<hr>
    		<form class="layui-form" action="">
    			<div class="layui-form-item">
				    <label class="layui-form-label">部门选择</label>
				    <div class="layui-input-block">
				      <select name="departmentId" lay-verify="required">
				        <option value=""></option>
				        <s:forEach var="m" items="${obj }">
				        	<option value="${m.id }">${m.name }</option>
				        </s:forEach>
				      </select>
				    </div>
				  </div>
			  <div class="layui-form-item">
			    <label class="layui-form-label">工号: </label>
			    <div class="layui-input-block">
			      <input type="text" name="no" id="no" required  lay-verify="required" placeholder="请输入工号" autocomplete="off" class="layui-input">
			    </div>
			  </div>
			 	<div class="layui-form-item">
			    <label class="layui-form-label">姓名: </label>
			    <div class="layui-input-block">
			      <input type="text" name="username" id="username" required  lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
			    </div>
			  </div>
			  <div class="layui-form-item">
			    <label class="layui-form-label">密码: </label>
			    <div class="layui-input-block">
			      <input type="text" name="password" id="password" required  lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
			    </div>
			  </div>
			  <div class="layui-form-item">
			    <div class="layui-input-block">
			      <button class="layui-btn" lay-submit lay-filter="add">添加</button>
			      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
			    </div>
			  </div>
			</form>
    	</div>
    </div>
  </div>
  
  <%@include file="/WEB-INF/common/admin/footer.jsp"%>
  
</div>
<%@include file="/WEB-INF/common/bottomjs.jsp"%>
<script>
(function(){
  var form = layui.form;
  //监听提交
  form.on('submit(add)', function(data){
    $.ajax({
    	url:"${base}/api/user/regist.api",
    	type: "post",
    	headers: Apicheck.getHeaders(),
    	data: {no: data.field.no, username: data.field.username, password: data.field.password, departmentId: data.field.departmentId},
    	success: function(result){
    		if(result.code == 1001){
    			layer.msg(result.msg, {icon:6});
    			$("#no").val("");
    			$("#username").val("");
    			$("#password").val("");
    		}else{
    			layer.msg(result.msg, {icon:5,anim:6});
    		}
    	}
    });
    return false;
  });
})()

</script>
</body>
</html>